package group.sicher.core.web.validator.handler;


import group.sicher.core.utils.ValidateUtils;
import group.sicher.core.web.validator.annotation.Ip;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * description:
 *
 * @Ip校验的注解 检验逻辑实现Handler
 * author:dengjinde
 * date:2018/11/26
 */
public class IpValidatorHandler implements ConstraintValidator<Ip, String> {

    private String message;

    @Override
    public void initialize(Ip constraintAnnotation) {
        this.message = constraintAnnotation.message();
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return ValidateUtils.isIPAddr(value);
    }
}
